var express = require('express');
var router = express.Router();
const { userModel } = require("../model/user_model")


// 登陆的校验
router.post("/login/check", async (req, res) => {
	let userData = req.body
	let data = await userModel.find(userData)
	if (data.length > 0) {
		res.send({
			data: {
				userName: "用户名",
				passWord: "密码",
				mobile: "手机号",
				head: "头像",
			},
			meta:{
				code: 200,
				msg: "登陆成功"
			}
			
		})
	} else {
		res.send({
			meta:{
				code: 201,
				msg: "登陆失败"
			}
			
		})
	}
})

// 注册
router.post("/login/add", async (req, res) => {
	let addUser = req.body
	let data = await userModel.find({ mobile: addUser.mobile })
	if (data.length > 0) {
		res.send({
			meta:{
				code: 201,
				msg: "该手机已被注册"
			}
			
		})
	} else {
		res.send({
			data,
			meta:{
				code: 200,
				msg: "注册成功"
			}
			
		})
	}
})




module.exports = router;
